<?php

/**
 * Created by PhpStorm.
 * User: li
 * Date: 15-12-6
 * Time: 下午8:35
 */
class Activity_comment extends MY_Model
{
    function __construct(){
        parent::__construct();
        $this->_table_name = 'activity_comment';
    }

    function get_by_activity_id($activity_id){
        $this->db->select('activity_comment.*');
        $this->db->select('users.username,users.id as uid');
        $this->db->where('activity_comment.id',$activity_id);
        $this->db->from($this->_table_name);
        $this->db->join('users','users.id = activity_comment.user_id');
        $query = $this->db->get();
        if($query->num_rows()>0){
            return $query->result_array();
        }
        return null;
    }

    function get_by_user_id($user_id){
        $this->db->select('activity_comment.*');
        $this->db->select('users.username,users.id as uid');
        $this->db->where('users.id',$user_id);
        $this->db->from($this->_table_name);
        $this->db->join('users','users.id = activity_comment.user_id');
        $query = $this->db->get();
        if($query->num_rows()>0){
            return $query->result_array();
        }
        return null;
    }
}